<script>
  function delay(ms) {
    return new Promise(function (resolve) {
      setTimeout(() => resolve(), ms)
    })
  }
  async function fn() {
    console.log(2)
    await delay(1000)
    console.log(3)
    await delay(2000)
    console.log(5)

    // Promise.resolve(1).then(() => {
    //   console.log(3)
    //   Promise.resolve(2).then(() => {
    //     console.log(5)
    //   })
    // })
  }

  console.log(1)
  fn()
  console.log(4)
</script>
